{% extends "base.html" %}

{% block title %}Mount Point Management{% endblock %}

{% block content %}
    {% if message %}
        <p style="color: green;">{{ message }}</p>
    {% endif %}
    <h2>Mount Point Management</h2>

    <form method="post">
        <div class="form-group">
            <label for="mount">Mount Point Name:</label>
            <input type="text" id="mount" name="mount" required>
        </div>
        <div class="form-group">
            <label for="password">Password:</label>
            <input type="password" id="password" name="password" required>
        </div>
        <button type="submit" name="add_mount">Add New Mount Point</button>
    </form>

    <table border="1" width="100%" class="mount-table">
        <thead>
            <tr>
                <th>Mount Point Name</th>
                <th>Status</th>
                <th>Manage</th>
            </tr>
        </thead>
        <tbody>
            {% for mount_id, mount, password in mounts %}
            <tr>
                <td>{{ mount }}</td>
                <td>
                    {% if mount in running_mounts %}
                        <span style="color: rgb(45, 11, 240);">Running</span>
                    {% else %}
                        <span style="color: red;">No Data</span>
                    {% endif %}
                </td>
                <td>
                    <form method="post" style="display: inline;">
                        <input type="hidden" name="update_mount" value="{{ mount_id }}">
                        <input type="text" name="mount" value="{{ mount }}" placeholder="New Mount Point Name">
                        <input type="password" name="password" placeholder="New Password">
                        <button type="submit">Update</button>
                    </form>
                    <form method="post" style="display: inline;">
                        <input type="hidden" name="delete_mount" value="{{ mount_id }}">
                        <button type="submit" onclick="return confirm('Are you sure you want to delete mount point {{ mount }}?')">Delete</button>
                    </form>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>

    <div class="pagination">
        <a href="#">Previous</a>
        <span>1 / 5</span>
        <a href="#">Next</a>
    </div>
{% endblock %}